<template>
  <div>
    <h2 class="mat-2">兄弟A</h2>
    <p class="mat-2">{{ brother }}</p>
    <Button class="mat-2" @click="clickBrotherA">传递数据给兄弟B</Button>
  </div>
</template>
<script>
import bus from './bus'
export default {
  data () {
    return {
      msg: '兄弟A的数据',
      brother: ''
    }
  },
  mounted () {
    bus.$on('brother-b-click', value => {
      this.brother = value
    })
  },
  methods: {
    // 兄弟 A 的点击事件
    clickBrotherA () {
      bus.$emit('brother-a-click', this.msg)
    }
  }
}
</script>
